package com.wangjie.page;

import com.wangjie.text.StrFormat;
import org.springframework.util.StringUtils;

/**
 * 分页数据
 *
 * @author jieshao
 * @date 2021/11/23 13:58
 */
public class PageDomain {
    /**
     * 当前记录起始索引
     */
    private Integer pageNum;

    /**
     * 每页显示记录数
     */
    private Integer pageSize;

    /**
     * 排序列
     */
    private String sortName;

    /**
     * 排序方式(asc 或者 desc)
     */
    private String sortOrder = "asc";

    public String getOrderBy() {
        if (StringUtils.isEmpty(sortName)) {
            return "";
        }
        return StrFormat.toUnderScoreCase(sortName) + " " + sortOrder;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public String getSortName() {
        return sortName;
    }

    public void setSortName(String sortName) {
        this.sortName = sortName;
    }

    public String getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(String sortOrder) {
        this.sortOrder = sortOrder;
    }
}